home *** CD-ROM | disk | FTP | other *** search
Wrap
(*************************************************** Ant Movie Catalog importation script www.antp.be/software/moviecatalog/ [Infos] Authors=ScorEpioN Title=Amazon.fr (Image Only) Description=Grande Image et titre Amazon.fr Site=http://www.amazon.fr Language=FR Version=11 du 23/05/2005 Requires=3.5 Comments=Ce script nΘcessite le fichier ScorEpioNCommonScript.pas|.==.| : ' ( ( ( ( /\ | "==()))))): ⌐ ScorEpioN ⌐| ( ( ( ( \_/ License=This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. | GetInfo=1 [Options] Mise α jour=1|1|0=Oui|1=Non Type de Lancement=0|0|0=Demande le titre avant de lancer le script|1=Ne demande pas le titre avant de lancer le script|2=Cherche la meilleur image sans confirmation Recherche sur le titre=0|0|0=Traduit|1=Original ***************************************************) program Amazon_FR; uses ScorEpioNCommonScript; const VersionScript = '11 du 23/05/2005'; urlDomain = 'amazon.'; NomScript = 'AMAZON.FR (IMAGE ONLY)'; timetosleep = 500; var MovieName, Address : string; i, compteur, premiereExecution: Integer; listeResultat: TStringList; //------------------------------------------------------------------------------ // RECUPERE GRANDE IMAGE AMAZON.FR //------------------------------------------------------------------------------ procedure imageAmazon(title : String); var adresseRecherche, Line : String; StartPos: Integer; begin PickTreeClear; adresseRecherche := 'http://www.amazon.fr/exec/obidos/search-handle-url/index=dvd-fr&field-keywords='+UrlEncode(title); Line := GetPage(adresseRecherche); if pos('satisfaisante pour votre recherche sur', Line) > 0 then begin exit; end else if (pos('Sur ce DVD', Line) > 0) or (pos('Amazon.fr : DVD:', Line) > 0) then begin StartPos := pos('<b class="sans">', Line); delete(Line, 1, StartPos-1); if CanSetPicture then GetPicture(recupImage(Line)); end else if pos('résultats au total pour', Line) > 0 then begin StartPos := pos('résultats au total pour', Line); delete(Line, 1, StartPos); recupAmazon(Line, title); end; end; //------------------------------------------------------------------------------ // CREATION DE LA LISTE DE RESULTAT //------------------------------------------------------------------------------ procedure recupAmazon(Line, title : String); var StartPos: Integer; couple, titre, adresse : String; begin listeResultat := TStringList.Create; StartPos := pos('/exec/obidos/ASIN/', Line); repeat {*********************** Boucle DEBUT ***********************} StartPos := pos('/exec/obidos/ASIN/', Line); delete(Line, 1, StartPos+length('/exec/obidos/ASIN/')-1); {*********************** Boucle DEBUT ***********************} //ajoute les films listeResultat.Add(recupTitle(Line)+'|'+recupImage(Line)); {*********************** Boucle FIN ***********************} StartPos := pos('<a href=/exec/obidos/ASIN/', Line); delete(Line, 1, StartPos+length('<a href=/exec/obidos/ASIN/')-1); StartPos := pos('/exec/obidos/ASIN/', Line); {*********************** Boucle FIN ***********************} until (StartPos = 0); if (GetOption('Type de Lancement') = 0) or (GetOption('Type de Lancement') = 1) then begin PickTreeAdd('Films trouvΘs pour ' + title + ' :', ''); for i:=0 to listeResultat.Count-1 do begin couple := listeResultat.GetString(i); titre := copy(couple,0,pos('|',couple)-1); adresse := copy(couple,pos('|',couple)+1,length(couple)-1); PickTreeAdd(titre , adresse); end; if (PickTreeExec(Address)=true) then begin if CanSetPicture then GetPicture(Address); end; end else if (GetOption('Type de Lancement') = 2) then begin trouveTitle(title); end; end; //------------------------------------------------------------------------------ // RECUPERE L'ADRESSE DE L'IMAGE //------------------------------------------------------------------------------ function recupImage(Line : String) : String; var ImageAddress : String; StartPos: Integer; begin StartPos := pos('http://images-eu.amazon.com/images/P/', Line); delete(Line, 1, StartPos-1); ImageAddress := copy(Line, 0, pos('"', Line) - 1); ImageAddress := StringReplace(ImageAddress, 'THUMBZZZ', 'LZZZZZZZ'); result := ImageAddress; end; //------------------------------------------------------------------------------ // RECUPERE LE TITRE //------------------------------------------------------------------------------ function recupTitle(Line : String) : String; var title : String; StartPos: Integer; begin StartPos := pos('<b>', Line); delete(Line, 1, StartPos-1); title := copy(Line, 1, pos('</b></a>', Line)-1); HTMLRemoveTags(title); title := StringReplace(title, #13#10, ''); result := title; end; //------------------------------------------------------------------------------ // SUPPRIME LES ACCENTS //------------------------------------------------------------------------------ function supprimeAccents(NomFilm : String) : String; begin NomFilm := supprimeLesAccents(NomFilm); delete(NomFilm, pos(' - ',NomFilm), length(NomFilm)); if (pos(', ',NomFilm) > 0) then delete(NomFilm, 1, pos(', ',NomFilm)+1); if (pos('(',NomFilm) > 0) then delete(NomFilm, pos('(',NomFilm), length(NomFilm)); if (pos(':',NomFilm) > 0) then delete(NomFilm, pos(':',NomFilm), length(NomFilm)); result := trim(NomFilm); end; //------------------------------------------------------------------------------ // COMPARE LE TITRE PASSE ET LE TITRE TROUVE //------------------------------------------------------------------------------ function compareTitle(titleAllo, title : String) : String; begin title := supprimeAccents(trim(AnsiLowerCase(title))); titleAllo := supprimeAccents(trim(AnsiLowerCase(titleAllo))); if (title = titleAllo) then begin result := 'OK'; end else begin result := 'KO'; end; end; //------------------------------------------------------------------------------ // TROUVE LE BON TITRE SI LE PREMIER N'EST PAS LE BON //------------------------------------------------------------------------------ procedure trouveTitle(title : String); var oK, couple, titre, adresse : String; begin for i:=0 to listeResultat.Count-1 do begin couple := listeResultat.GetString(i); titre := copy(couple,0,pos('|',couple)-1); adresse := copy(couple,pos('|',couple)+1,length(couple)-1); oK := compareTitle(title,titre); if oK = 'OK' then begin GetPicture(adresse); exit; end; end; listeResultat.Free; end; //------------------------------------------------------------------------------ // PROGRAMME PRINCIPAL //------------------------------------------------------------------------------ begin if CheckVersion(3,5,0) then begin if GetOption('Mise α jour') = 0 then begin execMenuMAJ(VersionScript,NomScript); exit; end; MovieName := recupTitreRecherche(GetOption('Recherche sur le titre')); if (GetOption('Type de Lancement') = 0) then begin if Input(NomScript+' by ScorEpioN', 'Entrez le titre du film :', MovieName) then begin imageAmazon(MovieName); end; end else begin if (premiereExecution = 0) then begin premiereExecution := -1; if (ShowConfirmation('Vous allez executer le script sans confirmation, cliquer sur ''''OUI'''' pour continuer') = True) then begin imageAmazon(MovieName); end else exit; end else begin imageAmazon(MovieName); end; end; end else ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)'); end.